﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CYTS.Aoyou.Framework.Log
{
    /// <summary>
    /// AOP日志记录者
    /// </summary>
    public class AOPLogger : Logger
    {
        private const string currentLoggerName = "CYTS.Aoyou.Framework.Log.AOPLogger";

        /// <summary>
        /// 记录错误
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="method"></param>
        /// <param name="args"></param>
        /// <param name="ex"></param>
        public static void LogError(string id, string type, string method, string args, Exception ex)
        {
            IAOPLog logger = GetLogger<IAOPLog>(currentLoggerName);
            if (logger.IsErrorEnabled)
            {
                logger.Error(id, type, method, args, ex);
            }
        }

        /// <summary>
        /// 记录消息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="method"></param>
        /// <param name="args"></param>
        /// <param name="returnType"></param>
        /// <param name="elapsedMilliseconds"></param>
        public static void LogInfo(string id, string type, string method, string args, string returnType, long elapsedMilliseconds)
        {
            IAOPLog logger = GetLogger<IAOPLog>(currentLoggerName);
            if (logger.IsInfoEnabled)
            {
                logger.Info(id, type, method, args, returnType, elapsedMilliseconds);
            }
        }
    }
}
